<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ include file="common/head.jsp" %>
<link type="text/css" rel="stylesheet" href="${ctx}/css/style.css" />
<script type="text/javascript">
 function checkName(){
	var name = document.getElementsByName("username");
	
	var username = name[0].value;
	
	
	var xmlHttpRequest = createRequest();
	
	xmlHttpRequest.open("POST","${pageContext.request.contextPath}/user",true);
	
	xmlHttpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	
	xmlHttpRequest.send("op=checkName&username="+username);
	
	xmlHttpRequest.onreadystatechange = function(){
		if(xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200){
			var err = document.getElementById('name_errormsg');
			console.log(xmlHttpRequest.responseText);
			err.innerHTML = xmlHttpRequest.responseText;
		}
	}
}

//根据不同浏览器创建XMLHttpReuqets对象
function createRequest(){
	try{
		//IE高版本 谷歌  火狐
		return new XMLHttpRequest();
	}catch(e){
		//如果是IE6
		try{
			return new ActiveXobject("Msxml2.XMLHTTP");
		}catch(a){
			//IE低版本
			return new ActiveXObject("Micosoft.XMLHTTP");
		}
		
	}
}
</script>
<div id="register" class="wrap">
	<div class="shadow">
		<em class="corner lb"></em>
		<em class="corner rt"></em>
		<div class="box">
			<h1>欢迎注册易买网</h1>
			<ul class="steps clearfix">
				<li class="current"><em></em>填写注册信息</li>
				<li class="last"><em></em>注册成功</li>
			</ul>
			<form id="regForm" method="post" action="${pageContext.request.contextPath}/user?op=registUser" >
				<table>
					<tr>
						<td class="field">用户名(*)：</td>
						<td>
							<input class="text" type="text" name="username"  id="username"  onblur="checkName()" />
							<td id = "name_errormsg"><font color="#999999"></font></td>
							<span></span>
						</td>
					</tr>
					<tr>
						<td class="field">真实姓名(*)：</td>
						<td><input class="text" type="text" name="userName" /><span></span></td>
					</tr>
					<tr>
						<td class="field">登录密码(*)：</td>
						<td><input class="text" type="password" id="password" name="password" /><span></span></td>
					</tr>
					<tr>
						<td class="field">确认密码(*)：</td>
						<td><input class="text" type="password" name="confirmPassword" /><span></span></td>
					</tr>
					<tr>
						<td class="field">性别(*)：</td>
						<td>
						  <input class="radio" type="radio" name="sex" value="male" checked="checked">
						  男性</input>
						  <input class="radio" type="radio" name="sex" value="female"						  
						  >女性</input>
						  <span></span></td>
					</tr>
					<tr>
						<td class="field">出生日期：</td>
						<td><input id="birthday" class="text" type="text" name="birthday" /><span></span></td>
					</tr>
					<tr>
						<td class="field">身份证：</td>
						<td><input class="text" type="text" name="identityCode" /><span></span></td>
					</tr>
					<tr>
						<td class="field">电子邮件：</td>
						<td><input class="text" type="text" name="email" /><span></span></td>
					</tr>
					<tr>
						<td class="field">手机(*)：</td>						
						<td><input class="text" type="text" name="mobile" /><span></span></td>
					</tr>
					<tr>
						<td class="field">收货地址(*)：</td>
						<td><input class="text" type="text" name="address" /><span></span></td>
					</tr>
					<tr>
						<td></td>
						<td><label class="ui-green"><input type="submit" name="submit" value="提交注册" /></label></td>
					</tr>
				</table>
			</form>
		</div>
	</div>
	<div class="clear"></div>
</div>
<%@ include file="common/foot.jsp" %>